package com.example.shop.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import lombok.experimental.Accessors;

/**
* <p>
* 订单
* </p>
*
* @author 作者
* @since 2022-05-29
*/
@Getter
@Setter
@Accessors(chain = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("`order`")
public class Order extends Model<Order> {

  private static final long serialVersionUID = 1L;
  /**
   * 该订单的唯一标识
   */
  @TableId(value = "order_id", type = IdType.ASSIGN_ID)
  private Long orderId;

  /**
   * 订单归属用户
   */
  @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
  private Long userId;

  /**
   * 订单中购买的商品
   */
  @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
  private Long goodsId;

  /**
   * 该订单关联的快递信息
   */
  private Long courierId;

  /**
   * 该订单关联的支付凭证
   */
  private String transactionId;
  /**
   * 支付的形式：微信支付、支付宝支付
   */
  private Integer paymentMethod;
  /**
   * 用户下单的时间（即支付成功时的时间）
   */
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
  private LocalDateTime orderTime;
  /**
   * 商家发货时间
   */
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
  private LocalDateTime deliveryTime;
  /**
   * 订单状态
   */
  private Integer orderState;

  /**
   * 用户购买的商品型号
   */
  private String userPurchasedGoodsClass;
  /**
   * 用户购买该型号的数量
   */
  private int userPurchasedNumber;
  /**
   * 用户的购买该商品的次数
   */
  private int userBuyTime;
  /**
   * 实际付款金额
   */
  private int realPay;

  @Override
  public String toString() {
    return "Order{" +
            "orderId=" + orderId +
            ", userId=" + userId +
            ", goodsId=" + goodsId +
            ", courierId=" + courierId +
            ", paymentMethod=" + paymentMethod +
            ", orderTime=" + orderTime +
            ", deliveryTime=" + deliveryTime +
            ", orderState=" + orderState +
            ", userPurchasedGoodsClass='" + userPurchasedGoodsClass + '\'' +
            ", userPurchasedNumber=" + userPurchasedNumber +
            ", userBuyTime=" + userBuyTime +
            ", realPay=" + realPay +
            '}';
  }
}
